package com.softeem.controller;

import com.softeem.entity.Info;
import com.softeem.service.InfoService;
import com.softeem.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/Info")
public class InfoController {

    @Autowired
    private InfoService infoService;

    @RequestMapping("/newInfo")
    @ResponseBody
    public Map<String, Object> newInfo(Info info){
        Map<String, Object> result = new HashMap<>();
        info.setSenderTime(new Date());
        try {
            result.put("state",infoService.newInfo(info));
            return result;
        }catch (Exception e){
            result.put("state",false);
            return result;
        }
    }
}
